import {
    getReportCaseList
} from '../../api/long-insure'
Page({
    data: {
        tabList: [{
            title: '全部'
        },
        {
            title: '待处理',
            color: 'yellow'
        },
        {
            title: '处理中',
            color: 'yellow'
        },
        {
            title: '已结案',
            color: 'green'
        },
        {
            title: '已驳回',
            color: 'red'
        },
        {
            title: '已撤案',
            color: 'grey'
        },
        {
            title: '确认金额',
            color: 'grey'
        }
        ],
        tab: 0,
        caseList: []
    },
    onLoad() {
        this.onTab()
    },
    async onTab(event) {
        const tab = event?.detail
        const result = await getReportCaseList({
            reportStatusList: tab ? (tab - 1) !== 2 ? (tab - 1) : '2,6' : ''
        })
        result.forEach((ele) => {
            // if (ele.reportStatus === 5) {
            //     ele.reportStatus = 1
            // }
            if (ele.reportStatus === 6) {
                ele.reportStatus = 2
            }
        })
        this.setData({
            tab: Number(event?.detail),
            caseList: result
        })
    },
    onAdd() {
        wx.navigateTo({
            url: '/packageLongInsure/pages/worker-list/worker-list?type=radio&isba=1&back=1&date=' + '',
        })
    },
    onCase(event) {
        const index = event.currentTarget.dataset.index
        wx.navigateTo({
            // url: '/packageLongInsure/pages/report-detail/report-detail?id='+this.data.caseList[index].id,
            url: '/packageLongInsure/pages/write-report/write-report?id=' + this.data.caseList[index].id,
        })
    }
})